#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    init();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_action_Open_triggered()
{
    QString filename =QFileDialog::getOpenFileName(this,"open an image");
    if (!filename.isEmpty()){
        loadimg(filename);
    }
}
void MainWindow::loadimg(QString filename){
    QPixmap pix(filename);
    QImage img = pix.toImage();
    this->cent->setimg(img);
    emit this->sigready(true);
}

void MainWindow::init(){
    this->cent = new Pic(this);
    this->setCentralWidget(cent);
    connect(this,SIGNAL(sigready(bool)),this->cent,SLOT(setready(bool)));
    connect(ui->actionRmFog,SIGNAL(triggered()),this->cent,SLOT(rmfog()));
    this->addToolBar("fog")->addAction(ui->actionRmFog);
}
